package paneles;

import java.text.NumberFormat;

import javax.swing.JLabel;
import javax.swing.table.DefaultTableCellRenderer ;

public class MonedaRender extends DefaultTableCellRenderer {

	public MonedaRender(){ 
		super();
		this.setHorizontalAlignment(JLabel.RIGHT);
		this.setAlignmentX(-10);
		}
	
	public void setValue(Object value){
		if(value == null)
			this.setText("");
		else{
			this.setText(NumberFormat.getCurrencyInstance().format(value));
			if(value instanceof Double){
				if(((Double) value).doubleValue()<0)
					this.setForeground(java.awt.Color.RED);
				else
					this.setForeground(java.awt.Color.BLACK);
			}
		}
	}
}
